package com.stms.dao;

import com.stms.pojo.Trucks;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
public interface TrucksRepository extends JpaRepository<Trucks,Integer> {
    @Modifying
    @Transactional
    @Query(value = "delete from trucks where id in(?)",nativeQuery = true)
    public void deleteBatch(List<Integer> id);

    @Query(value="select * from trucks where license=?",nativeQuery = true)
    public Trucks findByLicense(String license);

    Page<Trucks> findAll(Specification<Trucks> trucksSpecification, Pageable pageable);
}
